#pragma once
#include <scanner/scanner.h>
#include <string>
#include <memory>
#include <sstream>
#include <cassert>

namespace Test
{
    enum ScannerType
    {
        stNone,
        stWhiteSpace,
        stEOL,
        stComment,
        stString,
        stName,
        stDictBeg,
        stDictEnd,
        stArrayBeg,
        stArrayEnd,
        stNamesBeg,
        stNamesEnd,
        stToken,
    };

    struct Object
    {
        Object() : type(stNone)             {   }
        Object(ScannerType st) : type(st)   {   }

        ScannerType type;
        std::string	data;
    };

    struct Parser : public Pdf::Scanner<Parser>
    {
        Parser();
        ~Parser();

        std::auto_ptr<Object>   object;

        void                    onCharacter(char c);
        void                    onEnterWhiteSpace();
        void                    onLeaveWhiteSpace();
        void                    onEnterEOL();
        void                    onLeaveEOL();
        void                    onEnterComment();
        void                    onLeaveComment();
        void                    onEnterString();
        void                    onLeaveString();
        void                    onEnterName();
        void                    onLeaveName();
        void                    onEnterDictionary();
        void                    onLeaveDictionary();
        void                    onEnterArray();
        void                    onLeaveArray();
        void                    onEnterNames();
        void                    onLeaveNames();
        void                    onEnterToken();
        void                    onLeaveToken();
    };

    class ScannerTest
    {
    public:
        ScannerTest(const char *src);
        ~ScannerTest();

        void                    checkNext( ScannerType type, const std::string &data );

    private:
        std::istringstream      m_stream;
    };
}